from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from .channel_serializers import GoodsChannelsSerializers, GoodsChannelsTypesSerializers, GoodsCategoriesSerializers
from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory
from meiduo_admin.utils import MyPageNumberPagination


# 获取频道管理页数据
class GoodsChannelsView(ModelViewSet):
    pagination_class = MyPageNumberPagination
    serializer_class = GoodsChannelsSerializers
    queryset = GoodsChannel.objects.order_by("id").all()


# 获取频道管理频道组数据
class GoodsChannelsTypesView(ListAPIView):
    serializer_class = GoodsChannelsTypesSerializers
    queryset = GoodsChannelGroup.objects.all()


# 获取频道管理一级分类数据
class GoodsCategoriesView(ListAPIView):
    serializer_class = GoodsCategoriesSerializers
    queryset = GoodsCategory.objects.filter(parent=None).all()
